package com.xoa.controller.party;

import com.xoa.model.party.GridCheckWithBLOBs;
import com.xoa.model.party.GridEveromentcheck;
import com.xoa.model.party.MapOwnerinfo;
import com.xoa.service.party.FileUploadService;
import com.xoa.service.party.GridCheckService;
import com.xoa.service.party.GridEveromentcheckService;
import com.xoa.service.party.MapOwnerinfoService;
import com.xoa.util.ToJson;
import com.xoa.util.common.wrapper.BaseWrapper;
import com.xoa.util.common.wrapper.BaseWrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by gsb on 2017/9/7.
 */
@RestController
@RequestMapping("/gridCheck")
public class GridCheckController {
    @Autowired
    private GridCheckService gridCheckService;
    @Autowired
    private MapOwnerinfoService mapOwnerinfoService;


    /**
     * 添加
     *
     * @param gridCheck
     * @return
     */
    @RequestMapping("/insertSelective")
    public BaseWrapper insertSelective(GridCheckWithBLOBs gridCheck) {
        return gridCheckService.insertSelective(gridCheck);
    }

    /**
     * 修改
     *
     * @param gridCheck
     * @return
     */
    @RequestMapping("/updateByPrimaryKeySelective")
    public BaseWrapper updateByPrimaryKeySelective(GridCheckWithBLOBs gridCheck) {
        return gridCheckService.updateByPrimaryKeySelective(gridCheck);
    }

    /**
     * 删除
     *
     * @param
     * @return
     */
    @RequestMapping("/deleteByPrimaryKey")
    public BaseWrappers deleteByPrimaryKey(Integer checkId) {
        return gridCheckService.deleteByPrimaryKey(checkId);
    }

    /**
     * 详情
     *
     * @param
     * @return
     */
    @RequestMapping("/selectByPrimaryKey")
    public BaseWrapper selectByPrimaryKey(Integer checkId, HttpServletRequest request) {
        return gridCheckService.selectByPrimaryKey(checkId, request);
    }

    /**
     * 列表和导
     *
     * @param
     * @return
     */
    @RequestMapping("/selectList")
    public BaseWrappers selectList(HttpServletRequest request, HttpServletResponse response, String gridName, String checkType, String newsTime, String lastEditTime,
                                   String userId, String checkInfo, Integer page, Integer pageSize, String exportId, String userName
    ) {
        return gridCheckService.selectList(request, response, gridName, checkType, newsTime, lastEditTime, userId, checkInfo, page, pageSize, exportId,userName);
    }

    //列表带权限
    @RequestMapping("/selectqxList")
    public BaseWrappers selectqxList(HttpServletRequest request, HttpServletResponse response, String checkType,
                                     Integer page, Integer pageSize, boolean useFlag, String exportId, String gridName
    ) {
        return gridCheckService.selectqxList(request,response,checkType,page,pageSize,useFlag,exportId,gridName);
    }


    @ResponseBody
    @RequestMapping("/getStatistics")
    public BaseWrappers checkStatistics(HttpServletRequest request, String timeType, String queryType) {
        return gridCheckService.checkStatistics(timeType,queryType,request);
    }


    @ResponseBody
    @RequestMapping("/checkUpdateStatistics")
    public BaseWrappers checkUpdateStatistics(HttpServletRequest request, String timeType, String queryType, String startTime, String endTime, String typeDate) {
        return gridCheckService.checkUpdateStatistics(timeType,queryType,startTime,endTime,request,typeDate);
    }
    @ResponseBody
    @RequestMapping("/getStatisticsArrt")
    public ToJson getStatisticsArrt(String timeType, String startTime, String endTime, HttpServletRequest request, String paixu) {
        return gridCheckService.getStatisticsArrt(timeType,startTime,endTime,request,paixu);
    }


    @ResponseBody
    @RequestMapping("/getLastCheckMsg")
    public BaseWrappers getLastCheckMsg(){
        return gridCheckService.getLastCheckMsg();
    }

    @ResponseBody
    @RequestMapping("/gridCheckCount")
    public BaseWrapper gridCheckCount(){
        return gridCheckService.gridCheckCount();
    }


    /**
     * 手机端查询分析统计接口
     * 创建人：陈志才
     * 创建时间：2017-12-11
     * @return
     */
    @ResponseBody
    @RequestMapping("/checkEvent")
    public ToJson checkEvent(){
        return  gridCheckService.checkEvent();
    }


    /**
     * 创建人：季佳伟
     * 创建时间：2017-12-12
     * 方法说明：登录本人的巡查记录
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("/selectOwnList")
    public BaseWrappers selectOwnList(HttpServletRequest request, HttpServletResponse response, String gridName, String checkType, String newsTime, String lastEditTime,
                                      String userId, String checkInfo, Integer page, Integer pageSize, String exportId
    ) {
        return gridCheckService.selectOwnList(request, response, gridName, checkType, newsTime, lastEditTime, userId, checkInfo, page, pageSize, exportId);
    }


    @ResponseBody
    @RequestMapping("/selectGriChecki")
    public BaseWrappers selectGriChecki(HttpServletRequest request, String userName, String page, String pageSize, String timeType) {
        return gridCheckService.selectGriChecki(request,userName,Integer.valueOf(page), Integer.valueOf(pageSize),timeType);
    }

    @ResponseBody
    @RequestMapping("/gridByUserName")
    public BaseWrappers gridByUserName(HttpServletRequest request, String timeType, String startTime, String endTime , String userName, String gridIds, String type, String location, Integer page, Integer pageSize) throws Exception{
        return gridCheckService.gridByUserName(timeType,startTime,endTime,userName,gridIds,type,location,page,pageSize);
    }
    /**
     * 创建人：季佳伟
     * 创建时间：2018-01-29
     * 方法说明：巡检统计按社区或人员排行榜
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("/checkRank")
    public BaseWrapper checkRank(String rankType, String timeType, String startTime, String endTime){
        return gridCheckService.checkRank(rankType, timeType, startTime, endTime);
    }
    /**
     * 创建人：季佳伟
     * 创建时间：2018-01-29
     * 方法说明：巡检统计  社区或人员排行榜  一级穿透
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("/checkRankListDetail")
    public BaseWrapper checkRankListDetail(String rankType, Integer page, Integer pageSize, boolean useFlag,
                                           String gridId, String userId, String timeType, String startTime, String endTime){
        return gridCheckService.checkRankListDetail(rankType, page, pageSize, useFlag, gridId, userId, timeType, startTime, endTime);
    }
    /**
     * 创建人：季佳伟
     * 创建时间：2018-01-28
     * 方法说明：巡检统计  排行榜  二级穿透
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("/getThreeDetail")
    public BaseWrapper getThreeDetail(Integer page, Integer pageSize, boolean useFlag,
                                      String timeType, String gridId, String userId, String startTime, String endTime){
        return gridCheckService.getThreeDetail(page, pageSize, useFlag, timeType, gridId, userId, startTime, endTime);
    }
    @Autowired
    GridEveromentcheckService gridEveromentcheckService;
    @RequestMapping("getCheckCountInsert")
    public ToJson<GridEveromentcheck> getCheckCountInsert() {
        return  gridEveromentcheckService.getCheckCountInsert();
    }

    @Autowired
    private FileUploadService fileUploadService;
    @RequestMapping("/fileUpload")
    public BaseWrapper fileUpload(MultipartFile file){
        return  fileUploadService.fileUpload(file);
    }


    @RequestMapping("queryCoordinatesByName")
    public BaseWrapper queryCoordinatesByName(HttpServletRequest request, String name, String code){
        return  mapOwnerinfoService.queryCoordinatesByName(request,name,code);
    }

    @RequestMapping("updateByIdSelective")
    public BaseWrapper updateByIdSelective(HttpServletRequest request, MapOwnerinfo record){
        return  mapOwnerinfoService.updateByIdSelective(request,record);
    }

}
